[pull] master from ruby:master#698
Merged
pull[bot] merged 3 commits intoturkdevops:masterfrom Jan 20, 2026
Merged
Conversation
Creating state classes is pretty expensive.
Since they are not modifiable, we can reuse them instead.
Benchmark script:
```rb
require "ripper"
require "prism"
require "benchmark/ips"
codes = Dir["**/*.rb"].map { File.read(it) }
Benchmark.ips do |x|
x.config(time: 10)
x.report("prism") { codes.each { Prism::Translation::Ripper.lex(it) } }
x.report("ripper") { codes.each { Ripper.lex(it) } }
x.compare!
end
```
Before:
```
ruby 4.0.0 (2025-12-25 revision ruby/prism@553f1675f3) +PRISM [x86_64-linux]
Warming up --------------------------------------
prism 1.000 i/100ms
ripper 1.000 i/100ms
Calculating -------------------------------------
prism 0.293 (± 0.0%) i/s (3.42 s/i) - 3.000 in 10.248348s
ripper 0.633 (± 0.0%) i/s (1.58 s/i) - 7.000 in 11.055687s
Comparison:
ripper: 0.6 i/s
prism: 0.3 i/s - 2.16x slower
```
After
```
ruby 4.0.0 (2025-12-25 revision ruby/prism@553f1675f3) +PRISM [x86_64-linux]
Warming up --------------------------------------
prism 1.000 i/100ms
ripper 1.000 i/100ms
Calculating -------------------------------------
prism 0.486 (± 0.0%) i/s (2.06 s/i) - 5.000 in 10.280413s
ripper 0.635 (± 0.0%) i/s (1.58 s/i) - 7.000 in 11.027169s
Comparison:
ripper: 0.6 i/s
prism: 0.5 i/s - 1.31x slower
```
ruby/prism@bdde16554c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )